package com.moyq5.mvc.maker.test.bean.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;

import com.moyq5.mvc.maker.test.bean.embed.Owner;
import com.moyq5.mvc.maker.test.bean.enums.ProfitRefType;
import com.moyq5.mvc.maker.test.bean.enums.ProfitStatus;

/**
 * 分润
 * 
 * @author Moyq5
 * @date 2017年12月20日
 */
@Entity
@Table(name = "tra_profit")
@DynamicUpdate
public class TraProfit implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 分润ID
	 */
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "native")@GenericGenerator(name = "native", strategy = "native")
    @Column(name = "profit_id")
	private Long profitId;
	/**
     * 业务单号
     */
    @Column(name = "biz_no", length = 100, nullable = false)
    private String bizNo;
	/**
	 * 归属信息
	 */
	@Embedded
	private Owner owner;
	/**
	 * 分润来源类型
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "ref_type", precision = 2, nullable = false)
	private ProfitRefType refType;
	/**
	 * 消费者支付订单
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "order_id")
	private UserOrder userOrder;
	/**
	 * 纯利润（元)
	 */
	@Column(name = "pure", precision = 10, scale = 2, nullable = false)
	private BigDecimal pure;
	/**
	 * 状态
	 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "status", precision = 2, nullable = false)
	private ProfitStatus status;
    /**
     * 分润说明，由系统填充
     */
    @Column(name = "remark", length = 300)
	private String remark;
	/**
	 * （状态）变更时间
	 */
	@Column(name = "mod_time", nullable = false, columnDefinition="datetime")
	private Date modTime;
	/**
	 * 添加时间
	 */
	@Column(name = "add_time", nullable = false, columnDefinition="datetime")
	private Date addTime;
	
	@PrePersist
	public void prePersist() {
		if (null == addTime) {
			addTime = new Date();
		}
	}
	public Long getProfitId() {
		return profitId;
	}
	public void setProfitId(Long profitId) {
		this.profitId = profitId;
	}
	public ProfitRefType getRefType() {
		return refType;
	}
	public void setRefType(ProfitRefType refType) {
		this.refType = refType;
	}
	public UserOrder getUserOrder() {
		return userOrder;
	}
	public void setUserOrder(UserOrder userOrder) {
		this.userOrder = userOrder;
	}
	public BigDecimal getPure() {
		return pure;
	}
	public void setPure(BigDecimal pure) {
		this.pure = pure;
	}
	public ProfitStatus getStatus() {
		return status;
	}
	public void setStatus(ProfitStatus status) {
		this.status = status;
	}
	public Date getModTime() {
		return modTime;
	}
	public void setModTime(Date modTime) {
		this.modTime = modTime;
	}
	public Date getAddTime() {
		return addTime;
	}
	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}
	public Owner getOwner() {
		return owner;
	}
	public void setOwner(Owner owner) {
		this.owner = owner;
	}
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	public String getBizNo() {
		return bizNo;
	}
	public void setBizNo(String bizNo) {
		this.bizNo = bizNo;
	}

}
